const context = require('../globalContext');
module.exports.GloblaContextWS = ws => {
    ws.on('message', data => {
        console.log('globlaContext WebSocket action', data);
        if(data === 'TriggerSwitch'){
            context.TriggerSwitch = !context.TriggerSwitch;
        }

        if(data === 'synchronize'){
            
        }

        ws.send(JSON.stringify(context));
    });

    setInterval(() => {
        ws.send(JSON.stringify(context));
    }, context.SYNC_INTERVAL);
}